﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;

public partial class Administrator_SocicalNetworkAdd : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    BizSocialNetwork socicalnetwork = new BizSocialNetwork();


    protected void btnSubmit_Click(object sender, EventArgs e)
    {
        try
        {

            int status = 0;
            if (cbStatus.Checked)
            {
                status = 1;
            }
            else
            {
                status = 0;
            }



            if (fuLogo.HasFile)
            {
                //filename = fuLogo.FileName;
                fuLogo.SaveAs(Server.MapPath("~/LogoSocialNetwork/" + GetRandom() + "" + fuLogo.FileName));
            }
            string createdby = Session["username"].ToString();

            socicalnetwork.tblSocialNetworkInsert(txtSocialNetworkName.Text, fuLogo.FileName, int.Parse(txtSortDisplay.Text), txtLink.Text, txtDescription.Text, createdby, status);
            divMessage.InnerHtml = LibraryO2S.O2S_Message.Success("Hệ thống", "Thực hiện thành công");
            //Response.Redirect("SocialNetwork.aspx");
        }
        catch (Exception ex)
        {
            divMessage.InnerHtml = LibraryO2S.O2S_Message.Error("Lỗi", "Cập nhật không thành công phát hiện lỗi " + ex.Message);
        }

    }
    public int GetRandom()
    {
        Random rd = new Random();
        int a = rd.Next(1, 100);
        return a;
    }
    protected void Unnamed1_Click(object sender, EventArgs e)
    {
        Response.Redirect("~/Administrator/Administrator.aspx");

    }
}